import numpy as np
import matplotlib.pyplot as plt
import matplotlib.pylab as pylab

# 绘图参数全家桶
params = {
    'axes.labelsize': '14',
    'xtick.labelsize': '12',
    'ytick.labelsize': '12',
    'legend.fontsize': '12',
    'figure.figsize': '6, 4',
    'figure.dpi': '180',
    'figure.subplot.left': '0.154',
    'figure.subplot.right': '0.982',
    'figure.subplot.bottom': '0.219',
    'figure.subplot.top': '0.974',
    'pdf.fonttype': '42',
    'ps.fonttype': '42',
    'font.family': ['Times New Roman', 'SimSun'],
    'mathtext.fontset': 'cm'
}
pylab.rcParams.update(params)

color_1 = "#FF6666"
color_2 = "#EE9966"
color_3 = "#EECC66"
color_4 = "#66CC99"
color_5 = "#6699FF"
color_6 = "#9966FF"

fig, ax = plt.subplots()

# 折线图
x = np.arange(10) + 1  # the label locations
data = [[9.74, 9.89, 10.03, 30.56, 67.1, 80.3, 90.15, 92.61, 97.61, 98.39],
        [9.69, 9.73, 10.0, 11.7, 24.09, 69.87, 88.13, 89.35, 97.96, 98.47],
        [10.0, 9.74, 9.92, 9.97, 11.59, 46.48, 90.21, 95.5, 98.32, 98.88],
        [10.18, 9.81, 10.11, 10.08, 11.0, 24.66, 63.41, 92.35, 98.29, 98.54],
        [10.02, 9.88, 9.89, 10.03, 10.89, 16.92, 36.47, 90.29, 98.39, 98.93],
        [10.33, 10.06, 9.78, 9.61, 9.74, 9.97, 10.1, 11.54, 16.84, 48.74]]
plt.plot(x, data[0], linewidth=2.0, color=color_1, marker='o',
         markerfacecolor=color_1, markeredgewidth=1.5, markersize=8, label='$alpha=1.0$')
plt.plot(x, data[1], linewidth=2.0, color=color_2, marker='o',
         markerfacecolor=color_2, markeredgewidth=1.5, markersize=8, label="$alpha=0.9$")
plt.plot(x, data[2], linewidth=2.0, color=color_3, marker='o',
         markerfacecolor=color_3, markeredgewidth=1.5, markersize=8, label="$alpha=0.8$")
plt.plot(x, data[3], linewidth=2.0, color=color_4, marker='o',
         markerfacecolor=color_4, markeredgewidth=1.5, markersize=8, label="$alpha=0.7$")
plt.plot(x, data[4], linewidth=2.0, color=color_5, marker='o',
         markerfacecolor=color_5, markeredgewidth=1.5, markersize=8, label="$alpha=0.6$")
plt.plot(x, data[5], linewidth=2.0, color=color_6, marker='o',
         markerfacecolor=color_6, markeredgewidth=1.5, markersize=8, label="$alpha=0.5$")

ax.set_xticks([0, 2, 4, 6, 8, 10])
ax.set_xticklabels(['$0$', '$2$', '$4$', '$6$', '$8$', '$10$'])
ax.set_yticks([0, 20, 40, 60, 80, 100])
ax.set_yticklabels(['$0\\text{%}$',
                    '$20\\text{%}$',
                    '$40\\text{%}$',
                    '$60\\text{%}$',
                    '$80\\text{%}$',
                    '$100\\text{%}$'])
ax.set_xlabel('Epoch Number')
ax.set_ylabel('Attack Success Rate')

plt.xlim((0, 11))
plt.ylim((0, 110))

plt.legend(loc='upper left', ncol=1, columnspacing=1, prop={'size': 10})

plt.grid(linestyle="--", linewidth=0.5, color='black', alpha=0.5)

plt.tight_layout()

plt.savefig("./alpha-1.png", format='png')

plt.show()
